package com.hk.employeemanagementsystem.web.controller;

import com.hk.employeemanagementsystem.entity.NationEntity;
import com.hk.employeemanagementsystem.service.NationEntityService;
import com.hk.employeemanagementsystem.util.web.WebCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author by 何坤
 * @Classname NationController
 * @Description TODO
 * @Date 2020/1/2 22:58
 */
@RestController
@RequestMapping(value = "/nation")
public class NationController {

    private Logger logger = LoggerFactory.getLogger(NationController.class);

    @Autowired
    private NationEntityService nationEntityServiceImpl;

    @GetMapping(value = "/get")
    public Map<String, Object> selectAllNation(){
        Map<String, Object> tips = new HashMap<>();
        try {
            List<NationEntity> nationEntities = nationEntityServiceImpl.selectAllNation();
            tips.put(WebCode.SUCCESS, true);
            tips.put(WebCode.MSG, WebCode.SUCCESS_SELECT);
            tips.put("data", nationEntities);
        } catch (Exception e) {
            logger.info(e.getMessage());
            tips.put(WebCode.SUCCESS, false);
            tips.put(WebCode.MSG, WebCode.FAILURE_SELECT);
        }
        return tips;
    }

}
